import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/pages/home/home'
import HomeNew from '@/pages/home/HomeNew'
import cart from '@/pages/Cart/cart'
import my from '@/pages/My/my'
import AboutWe from '@/pages/My/AboutWe'
import goodDetail from '@/pages/Detail/goodDetail';
import goodDetailNew from '@/pages/Detail/goodDetailNew';
import order from '@/pages/order'
import orderNew from '@/pages/orderNew'
import author from '@/pages/author'
import choose from '@/pages/choose'
import news from '@/pages/News/news'
import newsDetail from '@/pages/News/newsDetail'
import parts from '@/pages/parts'
import change from '@/pages/Detail/Change'
import success from '../common/success'
import MyCollection from '@/pages/My/MyCollection'
import classify from "@/pages/Classify/classify"
import OrderDetails from "@/pages/OrderDetails"
import pay from "@/pages/pay/pay"
import address from "@/pages/address"
import add_address from "@/pages/add_address"
import my_test from "@/pages/MyTest"
import ercode from "@/pages/my/ErCode"
import PayRecord from "@/pages/my/PayRecord"
import feedback from "@/pages/my/FeedBack"
import question from "@/pages/my/Question"
import QuestionDetail from "@/pages/my/QuestionDetail"
import ActivityDetail from "@/pages/my/ActivityDetail"
import NewActivites from "@/pages/my/NewActivites"
import cylogin from "@/pages/login/CyLogin"
import login from "@/pages/login/Login"
import changepw from "@/pages/login/ChangePw"

Vue.use(Router);

export default new Router({
  routes: [
    {path: '/cylogin', name: 'cylogin', component: cylogin},
    {path: '/login', name: 'login', component: login},
    {path: '/changepw', name: 'changepw', component: changepw},
    // {path: '/login', name: 'login', component: login},
    {path: '/test', name: 'test', component: my_test},
    // {path: '/home', name: 'home', component: Home},
    {path: '/HomeNew', name: 'HomeNew', component: HomeNew},
    // {path: '/home', name: 'home', component: Home, meta: {index: 1}},
    {path: '/cart', name: 'cart', component: cart},
    {path: '/my', name: 'my', component: my},
    {path: '/PayRecord', name: 'PayRecord', component: PayRecord},
    {path: '/AboutWe', name: 'AboutWe', component: AboutWe},
    {path: '/ercode', name: 'ercode', component: ercode},
    {path: '/feedback', name: 'feedback', component: feedback},
    {path: '/question', name: 'question', component: question},
    {path: '/QuestionDetail', name: 'QuestionDetail', component: QuestionDetail},
    {path: '/goodDetailNew', name: 'goodDetailNew', component: goodDetailNew},
    {path: '/ActivityDetail', name: 'ActivityDetail', component: ActivityDetail},
    {path: '/NewActivites', name: 'NewActivites', component: NewActivites},
    {
      path: '/goodDetail',
      name: 'goodDetail',
      component: goodDetail,
      meta: {index: 0}
    },
    {
      path: '/orderNew',
      name: 'orderNew',
      component: orderNew,
      meta: {index: 0}
    },
    {
      path: '/order',
      name: 'order',
      component: order,
      children: [
        {
          path: '/order/OrderDetails',
          name: '/order/OrderDetails',
          component: OrderDetails,
        }
      ]
    },
    {path: '/author', name: 'author', component: author},
    {path: '/choose', name: 'choose', component: choose},
    {path: '/newsDetail', name: 'newsDetail', component: newsDetail},
    {path: '/news', name: 'news', component: news},
    {path: '/parts', name: 'parts', component: parts},
    {path: '/change', name: 'change', component: change},
    {path: '/success', name: 'success', component: success},
    {path: '/MyCollection', name: 'MyCollection', component: MyCollection},
    {path: '/classify', name: 'classify', component: classify},
    {path: '/OrderDetails', name: 'OrderDetails', component: OrderDetails},
    {
      path: '/pay',
      name: 'pay',
      component: pay
    },
    {
      path: '/address',
      name: 'address',
      component: address
    },
    {
      path: '/add_address',
      name: 'add_address',
      component: add_address
    },
    //找不到对应路由重定向到home页面
    {
      path: '*',
      redirect: '/HomeNew'
    }
  ],
  //路由切换页面始终回到最顶部
  // scrollBehavior(to, from, savedPosition) {
  //   return { x: 0, y: 0 }
  // }
})
